﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Medianamik.Core.ImportExport;
using System.IO;
using System.Collections;
using Medianamik.Core;

namespace Medianamik.UI.ImportExportManagement
{
    public partial class TestVincent : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var serializer = new JSonNodeDataSourceSerializer();

            var data = serializer.Deserialize(GetRecords());
            NodeDataSourceImporter importer = new NodeDataSourceImporter();
            importer.ImportData(data);

        }

        public string GetRecords()
        {
            var datasource = new Medianamik2NodeDataSource(new NodeFilter().CreatedSince(new DateTime(2008,10,28))) ;
            var serializer = new JSonNodeDataSourceSerializer();
            
            StringWriter sw = new StringWriter();

            serializer.Serialize(datasource.GetData(), sw);

            return sw.ToString();
        }

        //public Guid GetFirstNodeId()
        //{
        //    var serializer = new JSonNodeDataSourceSerializer();
           
        //    var data = serializer.Deserialize(GetRecords());
        //    return data.Records[0].NodeId;

        //}
    }
}
